package Game.Items.Others;

import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Vector2f;

import GUI.GuiManager;
import Game.Items.GameItem;
import Game.Objects.GameObject;
import Tools.Drawing.FontTagSystem;

/** Treasure map class
 * @author Aikidos
 */
public class GITreasureMap extends GameItem {

	public GITreasureMap() {
		super("Treasure Map");
		
		Category = ECategory.Other;
		
		_cost = 30;
		_weight = 0.09f;
	}

	@Override
	public boolean use() throws SlickException {
		if (_ownerGameObject.isPlayer())
		{
			GameObject[] chests = _ownerGameObject.getObjectManager().getObjectsByClass("Game.Objects.GOChest");
			for (GameObject chest : chests) {
				GuiManager.getGuiMap().addMark(chest.getCoord());
			}
			
			GameObject[] goldChests = _ownerGameObject.getObjectManager().getObjectsByClass("Game.Objects.GOGoldChest");
			for (GameObject goldChest : goldChests) {
				GuiManager.getGuiMap().addMark(goldChest.getCoord());
			}
			
			// Show message
			GuiManager.getMessenger().addMessage("[green]You[/green] used a [yellow]" + getName() + "[/yellow]");
			
			return true;
		}
		
		return false;
	}
	
	@Override
	public void drawInfo(Vector2f drawPos, Graphics g) {
		FontTagSystem.drawText("Description:", drawPos);
		
		drawPos.y += 20;
		
		FontTagSystem.drawText("Shows all chests on map", drawPos);
	}
	
}
